from flask import Flask, render_template, session, redirect, url_for, request

app = Flask(__name__)


@app.route('/index')
def index():
    return render_template("index.html")


@app.route('/test')
def test():
    return render_template("test.html")


@app.route('/test2')
def test2():
    return render_template("test2.html")

@app.route('/test33')
def test33():
    return render_template("test33.html")

@app.route('/test4')
def test4():
    return render_template("test4.html")



"""
这是一个展示Flask如何读取服务器本地图片, 并返回图片流给前端显示的例子
"""
def return_img_stream(img_local_path):
    """
    工具函数:
    获取本地图片流
    :param img_local_path:文件单张图片的本地绝对路径
    :return: 图片流
    """
    import base64
    img_stream = ''
    with open(img_local_path, 'r') as img_f:
        img_stream = img_f.read()
        img_stream = base64.b64encode(img_stream)
    return img_stream




if __name__ == '__main__':
    app.run()
